﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace REVISIONMAX30.DataObjects
{
    public class SourceDirectory : DataObjectBase
    {
        public SourceDirectory(string pDirectoryName)
        {
            this.DirectoryName = pDirectoryName;
        }

        public string DirectoryName { get; set; }
        public bool? ScanDirectoryRecusivly { get; set; }

        public string[] GetFiles()
        {
            if (!DirectoryExists()) return null;
            return System.IO.Directory.GetFiles(this.DirectoryName, "*.sql", ScanDirectoryRecusivly.BoolValue() ? System.IO.SearchOption.AllDirectories : System.IO.SearchOption.TopDirectoryOnly);
        }

        public bool DirectoryExists()
        {
            return System.IO.Directory.Exists(this.DirectoryName);
        }

        public Frame.FrResultType CopyFilesToLocal()
        {
           return Functions.CopyDirectoryWithFiles(DirectoryName, ScanDirectoryRecusivly.BoolValue(), "*.sql", false);
        }
    }
}
